package cn.kooki.app.duobao.ui.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import cn.kooki.app.duobao.R;

/**
 * Created by xiong on 2015/11/28.
 */
public class KindMenuAdapter extends BaseAdapter {

    private final String[] kindstitle;
    private final int[] imgres;
    private Context context;

    public KindMenuAdapter(Context context) {
        this.context = context;
        kindstitle = context.getResources().getStringArray(R.array.kind_array);
        imgres = new int[]{R.drawable.menu_ten_con,
                R.drawable.ic_kind_sjpb,
                R.drawable.ic_kind_dnbg,
                R.drawable.ic_kind_smyy,
                R.drawable.ic_kind_clxp,
                R.drawable.ic_kind_qtjp};
    }

    @Override
    public int getCount() {
        return kindstitle.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHoler viewHoler = null;
        if (convertView == null) {
            viewHoler = new ViewHoler();
            convertView = LayoutInflater.from(context).inflate(R.layout.layout_price_kind, parent, false);
            viewHoler.priceKindIcon = (ImageView) convertView.findViewById(R.id.price_kind_icon);
            viewHoler.priceKindName = (TextView) convertView.findViewById(R.id.price_kind_name);
            convertView.setTag(viewHoler);
        } else {
            viewHoler = (ViewHoler) convertView.getTag();
        }
        viewHoler.priceKindIcon.setImageResource(imgres[position]);
        viewHoler.priceKindName.setText(kindstitle[position]);

        return convertView;
    }

    class ViewHoler {
        ImageView priceKindIcon;
        TextView priceKindName;
    }

}
